/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.cms.link.entity;


import com.jeeplus.cms.support.validation.PatternExtend;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.core.persistence.DataEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.NotBlank;

/**
 * 链接Entity
 *
 * @author Sawyer
 * @version 2020-11-21
 */
@Getter
@Setter
@ToString
public class CmsLink extends DataEntity<CmsLink> {

    private static final long serialVersionUID = 1L;

    @Length(min = 2, max = 10, message = "链接名称长度必须介于 2 和 10 之间")
    @ExcelField(title = "链接名称", align = 2, sort = 1)
    private String name;

    @ExcelField(title = "链接logo", align = 2, sort = 2)
    @PatternExtend(regexp = "^.{5,1024}$", message = "logo路径最大长度不能超过1024")
    private String logo;

    @URL(message = "链接地址必须为合法网址")
    @ExcelField(title = "链接地址", align = 2, sort = 3)
    private String href;

    @ExcelField(title = "排序", align = 2, sort = 4)
    private Integer sort;

    @PatternExtend(regexp = "^[0-1]$", required = true, message = "标记无效")
    @ExcelField(title = "启用标记", align = 2, sort = 5)
    private String enableFlag;

    /**
     * 所属站点
     */
    @NotBlank(message = "所属站点不能为空")
    private String siteId;

    public CmsLink() {
        super();
        this.setIdType(IDTYPE_AUTO);
    }

    public CmsLink(String id) {
        super(id);
    }
}
